import { Component, OnInit , Input} from '@angular/core';
import { PushService } from '../push.service'
import { FeathersService } from 'app/api/feathers.service'
// tslint:disable-next-line:import-blacklist
import * as Rx from 'rxjs'
import Push from 'app/api/model/Push';

@Component({
  selector: 'app-num-page',
  templateUrl: './num-page.component.html',
  styleUrls: ['./num-page.component.css']
})
export class NumPageComponent implements OnInit {
  num: number
  // public service: any
  dataList: Rx.Observable<Push[]>

  constructor(
    private push: PushService
  ) {
    this.dataList = this.push.service
    // this.service = this.feathers.client.service('database/push')

    // this.service.on('created', () => this.updateDataList())
    // this.service.on('updated', () => this.updateDataList())
    // this.service.on('patch', () => this.updateDataList())
    // this.service.on('removed', () => this.updateDataList())
   }

  ngOnInit() {
    // this.getDataList()
    this.dataList = this.push.getDataList()
  }
  // getDataList(): Rx.Observable<Push[]> {
  //   this.updateDataList()
  //   return this.dataList
  // }

    // private updateDataList() {
    // const params = {
    //     paginate: {
    //       $limit: 5,
    //       $sort: {
    //         id: -1
    //       }
    //   }
    // }
    // this.service.find(params)
    //     .then((result: any) => {
    //       this.dataList.next(result.data)
    //       this.num = result.total
    //     })
    //     .catch((error: any) => {
    //       console.warn(error)
    //     })
    // }
}
